Testing some geometry routines in C++
[andmenj-acm.git] / 10370 - Above Average / 10370.cpp
blob601895c250dec507ec7c80922775ad53ca0d76ae
1 #include <stdio.h>
2 #include <iostream>
3 #include <math.h>
5 using namespace std;
7 int main()
9 int casos;
10 int n;
11 int grades[1000];
12 int superaron;
13 double promedio, porcentaje;
14 cin >> casos;
15 while (casos--){
16 //leer caso
17 cin >> n;
18 promedio = 0.0;
19 for (int i=0; i<n; i++){
20 cin >> grades[i];
21 promedio += grades[i];
23 promedio /= n;
24 //cout << "El promedio es: "<< promedio << endl;
25 superaron = 0;
26 for (int i=0; i<n; i++)
27 if (grades[i] > promedio)
28 superaron++;
29 //cout << superaron << " superaron el promedio." << endl;
30 porcentaje = (double)superaron * 100 / n;
31 porcentaje = floor(1000*porcentaje + 0.5)/1000; //round
32 printf("%.3f", porcentaje); cout << "%\n";
35 return 0;